@model EditImageViewModel

@{
	ViewBag.Title = Resources.Shared.AppName + " - " + string.Format(Resources.Shared.EditViewTitle, Model.IdentityDescription);
	string twoLettersCulture = new System.Globalization.CultureInfo(Culture).TwoLetterISOLanguageName;	
}

<div class="view-container">
  <div class="view-header-container">
    <h2 class="view-header">@string.Format(Resources.Shared.EditViewTitle, Model.IdentityDescription)</h2>
  </div>
  <!-- Top buttons -->
  <div class="view-button-container top-button-container">
    <input type="button" class="button back-button" title="@Resources.Shared.Back" onclick="document.location = '@Url.Action("Edit", "Product", new { id = Model.ProductId })'"/>
    <input type="button" class="button save-button" title="@Resources.Shared.Save" onclick="$('#ImageForm').submit()"/>	
  </div>
  <!-- Form begin -->
  <div class="entity-form-container">
    @using (Html.BeginForm("ChangeImage", "Product", FormMethod.Post, new { id = "ImageForm", enctype = "multipart/form-data" }))
    {
      @Html.ValidationSummary(true)
      <fieldset>
        <legend>@Resources.ImageResources.Image</legend>
		<div class="form">
          @Html.HiddenFor(model => model.Id)
				<div class="field">
				  <div class="label">
					@Html.Label(Resources.ImageResources.Name)
			  	  </div>
				  <div class="editor ">
					@Html.TextBoxFor(model => model.Name)
					@Html.ValidationMessageFor(model => model.Name)
				  </div>
				</div>
				<div class="field">
				  <div class="label">
					@Html.Label(Resources.ImageResources.Description)
			  	  </div>
				  <div class="editor ">
					@Html.TextBoxFor(model => model.Description)
					@Html.ValidationMessageFor(model => model.Description)
				  </div>
				</div>
				<div class="field">
				  <div class="label">
					@Html.Label(Resources.ImageResources.SortOrder)
			  	  </div>
				  <div class="editor number-editor">
					@Html.TextBoxFor(model => model.SortOrder)
					@Html.ValidationMessageFor(model => model.SortOrder)
				  </div>
				</div>
				<div class="field">
				  <div class="label">
					@Html.Label(Resources.ImageResources.Data)
				  </div>
				  <div class="editor">
					@if (Model.HasData)
                    {
					<a href="@Url.Action("DownloadBinary", "Image")/@Model.Id?p=Data" target="_blank">
						@if (Model.DataIsImage)
                        {
                        <img src="@Url.Action("DownloadBinary", "Image")/@Model.Id?p=Data" alt="Data" style="width:100%;" />
                        }
                        else
                        {
					        @(Resources.Shared.Download)
                        }
					</a>
					}
					<input type="file" id="Data" name="Data" />
				  </div>
				</div>
		        @Html.HiddenFor(model => model.ProductId)
        </div>
      </fieldset>
    }
    </div>
	<!-- Form end -->
 
</div>
@section Scripts {
	@Scripts.Render("~/bundles/jqueryval")
    <script src="@Url.Content("~/Scripts/cultures/methods_" + twoLettersCulture + ".js")" type="text/javascript"></script>
}
